package hku.cs.lunuo.voter.impl;

import hku.cs.lunuo.rank.DefaultLabel;
import hku.cs.lunuo.rank.model.Label;
import hku.cs.lunuo.voter.VotedGlobal;
import hku.cs.lunuo.voter.VotedUnit;
import hku.cs.lunuo.voter.Voter;

public class TMinos extends Voter {

	@Override
	public Label vote(VotedUnit u, VotedGlobal g) {
		int falseCases = u.tf.getFlsTimes();
		int trueCases = u.tf.getTruTimes();
		
		float perFalse;
		if (falseCases == 0)
			perFalse = 0;
		else
			perFalse = falseCases/ (float) g.getTotalFls();
		
		float perTrue;
		if (trueCases == 0)
			perTrue = 0;
		else
			perTrue = trueCases / (float) g.getTotalTru();
		
		float susc;
		if (perFalse + perTrue == 0)
			susc = 0;
		else if(perFalse + perTrue == 2)
			susc = perFalse/(perFalse+perTrue);
		else
			susc = perFalse/(perFalse+perTrue)-(1-perFalse)/(2-perFalse-perTrue);
		
		return new DefaultLabel(susc);
	}

}
